 //头像更换
 window.onload = function() {

     var inputFile = document.querySelector('[type="file"]')
     document.querySelectorAll('img')[1].onclick = function() {
         inputFile.click()
     }


     //支付方式自定义下拉列表

     var arrow = document.getElementsByTagName('i')[0]
     arrow.onclick = function() {
         document.getElementsByClassName('pay')[0].style.display = 'block'
     }
     var lis = document.getElementsByClassName('pay')[0].children
     var length = lis.length
     for (let i = 0; i < length; i++) {
         lis[i].onclick = function() {
             var payName = this.lastElementChild.innerHTML
             document.getElementsByClassName('payWay')[0].innerHTML = payName //赋值
             document.getElementsByClassName('pay')[0].style.display = 'none'
         }
     }


     function loadFile(inputFile) {
         var fileReader = new FileReader()
         var reg = /^image/gi
         var flag = reg.test(inputFile.files[0].type)
         if (inputFile.files[0].size < Math.pow(1024, 2) && flag) {
             fileReader.onload = function(e) {
                 document.querySelectorAll('img')[1].src = e.target.result
             }
             fileReader.readAsDataURL(inputFile.files[0])
         } else {
             alert("图片上传失败！")
         }

     }
     var month_olympic = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
     var month_normal = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
     var month_name = ["January", "Febrary", "March", "April", "May", "June", "July", "Auguest", "September", "October", "November", "December"];
     var holder = document.getElementById("days");
     var prev = document.getElementById("prev");

     var next = document.getElementById("next");
     var ctitle = document.getElementById("calendar-title");
     var cyear = document.getElementById("calendar-year");
     var my_date = new Date();
     var my_year = my_date.getFullYear();
     var my_month = my_date.getMonth();
     var my_day = my_date.getDate();

     function dayStart(month, year) {
         var tmpDate = new Date(year, month, 1);
         return (tmpDate.getDay());
     }

     function daysMonth(month, year) {
         var tmp = year % 4;
         if (tmp == 0) {
             return (month_olympic[month]);
         } else {
             return (month_normal[month]);
         }
     }

     function refreshDate() {
         var str = "";
         var totalDay = daysMonth(my_month, my_year); //获取该月总天数
         var firstDay = dayStart(my_month, my_year); //获取该月第一天是星期几
         var myclass;
         for (var i = 1; i < firstDay; i++) {
             str += "<li></li>"; //为起始日之前的日期创建空白节点
         }
         for (var i = 1; i <= totalDay; i++) {
             if ((i < my_day && my_year == my_date.getFullYear() && my_month == my_date.getMonth()) || my_year < my_date.getFullYear() || (my_year == my_date.getFullYear() && my_month < my_date.getMonth())) {
                 myclass = " class='lightgrey'"; //当该日期在今天之前时，以浅灰色字体显示
             } else if (i == my_day && my_year == my_date.getFullYear() && my_month == my_date.getMonth()) {
                 myclass = " class='green greenbox'"; //当天日期以绿色背景突出显示
             } else {
                 myclass = " class='darkgrey'"; //当该日期在今天之后时，以深灰字体显示
             }
             str += "<li" + myclass + ">" + i + "</li>"; //创建日期节点
         }
         holder.innerHTML = str; //设置日期显示
         ctitle.innerHTML = month_name[my_month]; //设置英文月份显示
         cyear.innerHTML = my_year; //设置年份显示

     }

     refreshDate(); //执行该函数

     prev.onclick = function(e) {
         e.preventDefault();
         my_month--;
         if (my_month < 0) {
             my_year--;
             my_month = 11;
         }
         refreshDate();
     }
     next.onclick = function(e) {
         e.preventDefault();
         my_month++;
         if (my_month > 11) {
             my_year++;
             my_month = 0;
         }

         refreshDate();
     }

 }